<?php
class ModuleShopsCustomerInfo extends Controller {
	public function customerInfo() {
		$this->language->load('module/customers');
      	$this->data['heading_title'] = $this->language->get('heading_title');

		$this->load->model('catalog/product');
		$this->load->model('catalog/review');
		$this->load->model('tool/seo_url');
		$this->load->helper('image');

		$this->data['products'] = array();
		$max_record =  $this->config->get('config_max_record_shop');
		$results = $this->model_catalog_product->getBestSellerProducts($max_record);
		foreach ($results as $result) {
			if ($result['image']) {
				$image = $result['image'];
			} else {
				$image = 'no_image.jpg';
			}

			$rating = $this->model_catalog_review->getAverageRating($result['product_id']);

			$special = $this->model_catalog_product->getProductSpecial($result['product_id']);

			if ($special) {
				$special = $this->currency->format($this->tax->calculate($special, $result['tax_class_id'], $this->config->get('config_tax')));
			} else {
				$special = FALSE;
			}

			$this->data['products'][] = array(
				'name'    => $result['name'],
				'price'   => $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))),
				'special' => $special,
				'image'   => image_resize($image, 38, 38),
				'href'    => $this->model_tool_seo_url->rewrite($this->url->http('product/product&product_id=' . $result['product_id']))
			);
		}

		if (!$this->config->get('config_customer_price')) {
			$this->data['display_price'] = TRUE;
		} elseif ($this->customer->isLogged()) {
			$this->data['display_price'] = TRUE;
		} else {
			$this->data['display_price'] = FALSE;
		}

		$this->template = $this->config->get('config_template') . 'shop/customerinfo.phtml';
		$customerInfo = $this->fetch($this->template);
		return $customerInfo;
	}
}
?>